import request from '@/utils/request';
import { AxiosPromise } from 'axios';
import { BuildingTreeVO, BuildingTreeForm, BuildingTreeQuery } from '@/api/dormitory/buildingTree/types';

/**
 * 查询宿舍楼管理列表
 * @param query
 * @returns {*}
 */

export const listBuildingTree = (query?: BuildingTreeQuery): AxiosPromise<BuildingTreeVO[]> => {
  return request({
    url: '/dormitory/buildingTree/list',
    method: 'get',
    params: query
  });
};

/**
 * 查询宿舍楼管理详细
 * @param id
 */
export const getBuildingTree = (id: string | number): AxiosPromise<BuildingTreeVO> => {
  return request({
    url: '/dormitory/buildingTree/' + id,
    method: 'get'
  });
};

/**
 * 新增宿舍楼管理
 * @param data
 */
export const addBuildingTree = (data: BuildingTreeForm) => {
  return request({
    url: '/dormitory/buildingTree',
    method: 'post',
    data: data
  });
};

/**
 * 修改宿舍楼管理
 * @param data
 */
export const updateBuildingTree = (data: BuildingTreeForm) => {
  return request({
    url: '/dormitory/buildingTree',
    method: 'put',
    data: data
  });
};

/**
 * 删除宿舍楼管理
 * @param id
 */
export const delBuildingTree = (id: string | number | Array<string | number>) => {
  return request({
    url: '/dormitory/buildingTree/' + id,
    method: 'delete'
  });
};
